import { Injectable } from '@angular/core';
import { RestService } from '@abp/ng.core';
import { Observable } from 'rxjs';
import { map } from 'rxjs/operators';

// 通用的下拉框选项数据结构
export interface SelectItem<T = string> {
  id: T;
  name: string;
}

@Injectable({
  providedIn: 'root',
})
export class LookupService {
  apiName = 'app';

  constructor(private restService: RestService) {}

  getShippers(): Observable<SelectItem[]> {
    return this.restService.request<any, SelectItem[]>({
      method: 'GET',
      url: '/api/app/lookup/shippers'
    });
  }

  getWarehouses(): Observable<SelectItem<number>[]> {
    return this.restService.request<any, SelectItem<number>[]>({
      method: 'GET',
      url: '/api/app/lookup/warehouses'
    });
  }

  getReservedWarehouseAreas(): Observable<SelectItem<number>[]> {
    return this.restService.request<any, SelectItem<number>[]>({
      method: 'GET',
      url: '/api/app/lookup/reserved-warehouse-areas'
    });
  }

  getOrderTypes(): Observable<SelectItem<number>[]> {
    return this.restService.request<any, SelectItem<number>[]>({
      method: 'GET',
      url: '/api/app/lookup/order-types'
    });
  }

  getPlatforms(): Observable<SelectItem<number>[]> {
    return this.restService.request<any, SelectItem<number>[]>({
      method: 'GET',
      url: '/api/app/lookup/platforms'
    });
  }
} 